#include "P3Error.h"
#include "P3_StateMachine.h"
#include "P3_OperatorLib.h"
#include <iostream>

#include <windows.h>

using namespace std;

extern P3StateMachine* gpStateMachine;

void
P3Error::DebugMessage( const string& message )
{
  Warning( message );
}

void
P3Error::Warning( const string& message )
{
  if( message.length() > 1 )
  {
    if( gpStateMachine && gpStateMachine->CallbackFunction( P3_OnWarningMessage ) )
      gpStateMachine->ExecuteCallback( P3_OnWarningMessage, message.c_str() );
    else
    {
      ::MessageBoxA( NULL, message.c_str(), "P300 Operator", MB_OK );
    }
  }
}

void
P3Error::ConfigurationError( const string& message )
{
  if( message.length() > 1 )
  {
    if( gpStateMachine && gpStateMachine->CallbackFunction( P3_OnErrorMessage ) )
      gpStateMachine->ExecuteCallback( P3_OnErrorMessage, message.c_str() );
    else
    {
      ::MessageBoxA( NULL, message.c_str(), "P300 Operator Error", MB_OK );
    }
  }
}

void
P3Error::RuntimeError( const string& message )
{
  ConfigurationError( message );
}

void
P3Error::LogicError( const string& message )
{
  ConfigurationError( message );
}
